﻿@model TaoNiuOA.Models.Task
@{
    ViewBag.Title = "发布任务";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>发布任务</legend>
        <div id="tip" style="color: Red; text-align: center; font-size: larger;">
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.TaskTypeID)
        </div>
        <div class="editor-field">
            @Html.DropDownList("TaskTypeID", "请选择类型")
            @Html.ValidationMessageFor(model => model.TaskTypeID)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Content)
        </div>
        <div class="editor-field">
            <textarea name="content" style="width: 800px; height: 350px; visibility: hidden;"></textarea>
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Level)
        </div>
        <div class="editor-field">
            <select id="Level" name="Level">
                <option value="0">低</option>
                <option value="1" selected="selected">普通</option>
                <option value="2">高</option>
                <option value="3">紧急</option>
            </select>
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Point)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Point)
            @Html.ValidationMessageFor(model => model.Point)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ProjectLast)
        </div>
        <div class="editor-field">
            <input type="text" id="ProjectLast" name="ProjectLast" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                class="Wdate" />
            @Html.ValidationMessageFor(model => model.ProjectLast)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.TotalDays)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TotalDays)
            @Html.ValidationMessageFor(model => model.TotalDays)
        </div>
        <p>
            <input type="submit" value="发布" onclick="return che();" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("返回任务列表", "Index")
</div>
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="../../Plusins/timeplus/WdatePicker.js" type="text/javascript"></script>
<script src="../../Plusins/kindeditor/kindeditor-min.js" type="text/javascript"></script>
<script src="../../Plusins/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
<script type="text/javascript">
    //编辑器
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]', {
            uploadJson: '/plusins/kindeditor/asp.net/upload_json.ashx',
            fileManagerJson: '/plusins/kindeditor/asp.net/file_manager_json.ashx',
            allowFileManager: true
        });
    });

    function che() {
        var tip = document.getElementById("tip");
        var typeid = document.getElementById("TaskTypeID");
        var proLast = document.getElementById("ProjectLast");
        var point = document.getElementById("Point");
        var totalDay = document.getElementById("TotalDays");
        if (typeid.value == "") {
            alert("请选择任务类型");
            typeid.focus();
            return false;
        }
        if (parseInt(point.value) < 0) {
            alert("任务绩效不能小于0");
            point.focus();
            return false;
        }
        if (parseInt(totalDay.value) < 0) {
            alert("任务天数不能小于0");
            totalDay.focus();
            return false;
        }
        if (proLast.value == "") {
            alert("请赶写任务期限.");
            proLast.focus();
            return false;
        }
        else {
            var inputDate =Date.p(proLast.value);
            var now =Date.parse(new Date());
            if (inputDate < now) {
                alert("任务期限要大于当前时间");
                return false;
            }
        }
    }
</script>
